package com.jhws.common.pay.bo;

import com.jhws.business.customer.bo.PayCustomer;
import com.jhws.business.customer.bo.PayCustomerSecret;
import com.jhws.business.customer.service.PayCustService;
import com.jhws.common.pay.service.OrderService;
import com.jhws.sys.user.bo.TblUserDimBo;
import com.jhws.sys.user.service.ITblUserDimService;
import com.jhws.util.LogHelper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
public class PayTestOrderModule implements IOrderPayModule{

    @Resource
    private OrderService orderService;
    @Resource
    private PayCustService payCustService;

    private String PAY_MODULE = "TEST";

    private String [] name = {"PAY_TEST"};
    @Override
    public String[] getModuleName() {
        return name;
    }

    @Override
    public String getPayModuleName() { return PAY_MODULE; }

    @Override
    public boolean preCheck(Order order) {
        return true;
    }

    @Override
    public void handle(Order order) throws Exception {

    }

    @Override
    @PostConstruct
    public void registerModule() {
        orderService.registerModule(this);
    }

    @Override
    public PayCustomerSecret findCustomerSecret(Order order) throws Exception {
        String userName = order.getAttach();
        LogHelper.d("PAY_TEST findCustomerId "+userName);
        List<PayCustomerSecret> list = payCustService.findCustomerSecretsByWhere("creator = '"+userName+"' and type = '"+order.getPayType()+"'");
        if(list == null || list.size() == 0)
            return null;

        return list.get(0);
    }

    @Override
    public void setCustomerId(String id, Long customId) throws Exception {

    }

    @Override
    public Map getDetailInfoForOrder(Order order) {
        return null;
    }

    @Override
    public String[] getModuleDesc() {
        return new String[0];
    }

    @Override
    public List<PayModuleInfo> getPayModuleInfo(String orderType, String commCode) {
        return null;
    }
}
